%Extract data from edf+ file using eeglab functions
%filename is the name of the edf file to read
%data is a struct containing the data and information needed to create a fieldtrip data structure 
function [data]=readEDFplus(filename)

toImport=pop_biosig(filename);
data.events=toImport.event;

data.data=toImport.data(1:end-1,:);

data.label=strtok({toImport.chanlocs.labels},'.');
data.label=data.label(1:end-1)';%all channels other than annotation ones

data.fsample=toImport.srate;